<?php
/*
 * @Author: 哲学家乔布斯 <wuyangii@qq.com>
 * @Date: 2022-10-25 20:19:21
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-10-25 20:22:43
 * @Descripttion: 
 */


namespace app\common\model;

use think\Model;

class Coupon extends Base
{
    protected $insert = ['addtime'];

    //---------------自动完成----------------------
    protected function setAddtimeAttr()
    {
        return time();
    }
    public function getAddtimeTextAttr($value, $data){
        return date('Y-m-d H:i:s', $data['addtime']);
    }
   

    public function getImageTextAttr($value,$data){
        return $data['image'] ? cdnurl($data['image'],true) : "";
    }
    public function getTypeTextAttr($value,$data){
        $arr = [
            1 => "无门槛",  2 => "满减",  3 => "指定商品",
        ];
        return $arr[$data['type']];
    }
    public function getBusUsernameAttr($value,$data){
        return empty($data['user_id']) ? : (new \app\common\model\Bus())->where(['id' => $data['user_id']])->value('user_name');
    }
    public function getGoodsTitleAttr($value,$data){
        return empty($data['goods_id']) ? : (new \app\common\model\Goods())->where(['id' => $data['goods_id']])->value('title');
    }
  
}
